import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '姓名',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '年龄',
    align:"center",
    dataIndex: 'age'
   },
   {
    title: '性别',
    align:"center",
    dataIndex: 'sex_dictText'
   },
   {
    title: '生日',
    align:"center",
    dataIndex: 'birthday',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '星座',
    align:"center",
    dataIndex: 'zodiacSign_dictText'
   },
   {
    title: '血型',
    align:"center",
    dataIndex: 'bloodType_dictText'
   },
   {
    title: '职业',
    align:"center",
    dataIndex: 'occupation'
   },
   {
    title: '头像',
    align:"center",
    dataIndex: 'avatar_dictText'
   },
   {
    title: '头像背景',
    align:"center",
    dataIndex: 'avatarBackground_dictText'
   },
   {
    title: '简介',
    align:"center",
    dataIndex: 'introduction'
   },
   {
    title: '排序',
    align:"center",
    sorter: true,
    dataIndex: 'sort'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "姓名",
      field: 'name',
      component: 'Input',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '姓名',
    field: 'name',
    component: 'Input',
  },
  {
    label: '年龄',
    field: 'age',
    component: 'InputNumber',
  },
  {
    label: '性别',
    field: 'sex',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"sex"
     },
  },
  {
    label: '生日',
    field: 'birthday',
    component: 'DatePicker',
  },
  {
    label: '星座',
    field: 'zodiacSign',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"m_zodiac_sign"
     },
  },
  {
    label: '血型',
    field: 'bloodType',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"m_blood_type"
     },
  },
  {
    label: '职业',
    field: 'occupation',
    component: 'Input',
  },
  {
    label: '头像',
    field: 'avatar',
    component: 'JSearchSelect',
    componentProps:{
       dict:"m_resource,name,id"
    },
  },
  {
    label: '头像背景',
    field: 'avatarBackground',
    component: 'JSearchSelect',
    componentProps:{
       dict:"m_resource,name,id"
    },
  },
  {
    label: '简介',
    field: 'introduction',
    component: 'InputTextArea',
  },
  {
    label: '排序',
    field: 'sort',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  name: {title: '姓名',order: 0,view: 'text', type: 'string',},
  age: {title: '年龄',order: 1,view: 'number', type: 'number',},
  sex: {title: '性别',order: 2,view: 'radio', type: 'string',},
  birthday: {title: '生日',order: 3,view: 'date', type: 'string',},
  zodiacSign: {title: '星座',order: 4,view: 'list', type: 'string',dictCode: 'm_zodiac_sign',},
  bloodType: {title: '血型',order: 5,view: 'list', type: 'string',dictCode: 'm_blood_type',},
  occupation: {title: '职业',order: 6,view: 'text', type: 'string',},
  avatar: {title: '头像',order: 7,view: 'sel_search', type: 'string',dictTable: "m_resource", dictCode: 'id', dictText: 'name',},
  avatarBackground: {title: '头像背景',order: 8,view: 'sel_search', type: 'string',dictTable: "m_resource", dictCode: 'id', dictText: 'name',},
  introduction: {title: '简介',order: 9,view: 'textarea', type: 'string',},
  sort: {title: '排序',order: 10,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}